package com.shuoyue.ycgk.ui.main.today_count;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.TodayQuestion;
import com.shuoyue.ycgk.utils.MyRichTextHelper;

import java.util.List;

public class TodayQuestionAdapter extends AppBaseQuickAdapter<TodayQuestion> {
    public TodayQuestionAdapter(@Nullable List<TodayQuestion> data) {
        super(R.layout.item_today_question, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TodayQuestion item) {
        String type = "";
        switch (item.getQuestionType()) {
            case 1:
                type = "单选题";
                break;
            case 2:
                type = "多选题";
                break;
            case 3:
                type = "判断题";
                break;
        }

        helper.setText(R.id.type, (helper.getAdapterPosition() + 1) + "." + type);
        MyRichTextHelper.showRich(mContext, item.getStem(), helper.getView(R.id.title));
        helper.setText(R.id.time, item.getUpdateTime());
        helper.setText(R.id.right_ans, item.getQuestionType() == 3 ? ("1".equals(item.getRightKey()) ? "正确" : "错误") : item.getRightKey());

        if (item.getQuestionType() == 3) {
            String myAnsKey = item.getAnswer();
            if ("1".equals(item.getAnswer())) {
                myAnsKey = "正确";
            }
            if ("2".equals(item.getAnswer())) {
                myAnsKey = "错误";
            }
            if ("NO".equals(item.getAnswer())) {
                myAnsKey = "不会";
            }
            helper.setText(R.id.mine_ans, myAnsKey);
        } else {
            if ("NO".equals(item.getAnswer())) {
                helper.setText(R.id.mine_ans, "不会");
            } else {
                helper.setText(R.id.mine_ans, item.getAnswer());
            }
        }

//        helper.setText(R.id.mine_ans, item.getAnswer());
        helper.setText(R.id.use_time, item.getSecondsStr());
    }
}
